#include <stdlib.h>
#include <thread>
#include "task.hpp"
#include "ThreadPool.hpp"
#include "Thread.hpp"

void run()
{
    while (true)
    {
        printf("我是线程:\n");
        sleep(1);
    }

}
int main()
{
    pool<task>::GetInstance()->start();
    // std::thread t(run,10, 20 ,30.76);
    // t.join();
    // Thread t(run);
    // t.run();
    // t.join();
    // srand(time(NULL));
    // printf("run\n");
    // pool<task> *pl = new pool<task>(5);

    // pl->start();
    // sleep(3);
    while (true)
    { 
      // 构建任务
      int data1 = rand() % 10;
      int data2 = rand() % 10 + 1;
      char op = g_op[rand() % 4];
      task t(data1, data2, op);
      // 交给线程池
      printf("task:%s\n", t.gettask().c_str());
      pool<task>::GetInstance()->push(t);
      sleep(1);
    }
}